import { http } from "@/utils/http";
import { baseUrlApi } from "@/utils/utils";

//===========================================================================
//获取个人资料10.10.10.41:8080/api/me
export const getProfile = (params?: object) => {
  return http.request<any>("get", baseUrlApi("api/me"), { params });
};
//更新个人资料
export const updateProfile = (data?: object) => {
  return http.request<any>("put", baseUrlApi("api/me/profile"), { data });
};

//============================================================================
//新闻 start

//获取参数
export const getNewsEnums = (params?: object) => {
  return http.request<any>("get", baseUrlApi("api/news/enums"), {
    params
  });
};

//新建
export const addNews = (data?: object) => {
  return http.request<any>("post", baseUrlApi("api/news"), { data });
};

//获取某个
export const getNews = (id: number, params?: object) => {
  return http.request<any>("get", baseUrlApi(`api/news/${id}?view=UPDATE`), {
    params
  });
};
//更新某个

export const updateNews = (id: number, data?: object) => {
  return http.request<any>("put", baseUrlApi(`api/news/${id}`), { data });
};
//删除某个

export const deleteNews = (id: number, data?: object) => {
  return http.request<any>("delete", baseUrlApi(`api/news/${id}`), { data });
};
//列表
export const newsList = (params?: object) => {
  return http.request<any>("get", baseUrlApi("api/news?view=ADMIN"), {
    params
  });
};

//============================================================================
//调解申请 start

//获取参数
export const getCasesEnums = (params?: object) => {
  return http.request<any>("get", baseUrlApi("api/cases/enums"), {
    params
  });
};
//新建
export const addCases = (data?: object) => {
  return http.request<any>("post", baseUrlApi("api/cases"), { data });
};

//获取某个
export const getCases = (id: number, params?: object) => {
  return http.request<any>("get", baseUrlApi(`api/cases/${id}?view=UPDATE`), {
    params
  });
};
//更新某个

export const updateCases = (id: number, data?: object) => {
  return http.request<any>("put", baseUrlApi(`api/cases/${id}`), { data });
};
//删除某个

export const deleteCases = (id: number, data?: object) => {
  return http.request<any>("delete", baseUrlApi(`api/cases/${id}`), { data });
};
//列表
export const casesList = (params?: object) => {
  return http.request<any>("get", baseUrlApi("api/cases?view=ADMIN"), {
    params
  });
};

//============================================================================
//组织 start

//获取参数
export const getOrganizationsEnums = (params?: object) => {
  return http.request<any>("get", baseUrlApi("api/organizations/enums"), {
    params
  });
};
//新建
export const addOrganizations = (data?: object) => {
  return http.request<any>("post", baseUrlApi("api/organizations"), { data });
};

//获取某个
export const getOrganizations = (id: number, params?: object) => {
  return http.request<any>(
    "get",
    baseUrlApi(`api/organizations/${id}?view=UPDATE`),
    {
      params
    }
  );
};
//更新某个

export const updateOrganizations = (id: number, data?: object) => {
  return http.request<any>("put", baseUrlApi(`api/organizations/${id}`), {
    data
  });
};
//删除某个

export const deleteOrganizations = (id: number, data?: object) => {
  return http.request<any>("delete", baseUrlApi(`api/organizations/${id}`), {
    data
  });
};
//列表
export const organizationsList = (params?: object, view: string = "ADMIN") => {
  return http.request<any>(
    "get",
    baseUrlApi(`api/organizations?view=${view}`),
    {
      params
    }
  );
};

//============================================================================
//商户 start

//获取参数
export const getMerchantsEnums = (params?: object) => {
  return http.request<any>("get", baseUrlApi("api/merchants/enums"), {
    params
  });
};
//新建
export const addMerchants = (data?: object) => {
  return http.request<any>("post", baseUrlApi("api/merchants"), { data });
};

//获取某个
export const getMerchants = (id: number, params?: object) => {
  return http.request<any>(
    "get",
    baseUrlApi(`api/merchants/${id}?view=UPDATE`),
    {
      params
    }
  );
};
//更新某个

export const updateMerchants = (id: number, data?: object) => {
  return http.request<any>("put", baseUrlApi(`api/merchants/${id}`), {
    data
  });
};
//删除某个

export const deleteMerchants = (id: number, data?: object) => {
  return http.request<any>("delete", baseUrlApi(`api/merchants/${id}`), {
    data
  });
};
//列表
export const merchantsList = (params?: object) => {
  return http.request<any>("get", baseUrlApi("api/merchants?view=ADMIN"), {
    params
  });
};

//============================================================================
//角色 start

//获取参数
export const getRolesEnums = (params?: object) => {
  return http.request<any>("get", baseUrlApi("api/roles/enums"), {
    params
  });
};
//新建
export const addRoles = (data?: object) => {
  return http.request<any>("post", baseUrlApi("api/roles"), { data });
};

//获取某个
export const getRoles = (id: number, params?: object) => {
  return http.request<any>("get", baseUrlApi(`api/roles/${id}?view=UPDATE`), {
    params
  });
};
//更新某个

export const updateRoles = (id: number, data?: object) => {
  return http.request<any>("put", baseUrlApi(`api/roles/${id}`), {
    data
  });
};
//删除某个

export const deleteRoles = (id: number, data?: object) => {
  return http.request<any>("delete", baseUrlApi(`api/roles/${id}`), {
    data
  });
};
//列表
export const rolesList = (params?: object) => {
  return http.request<any>("get", baseUrlApi("api/roles?view=ADMIN"), {
    params
  });
};

//============================================================================
//权限 start

//获取参数
export const getPermissionsEnums = (params?: object) => {
  return http.request<any>("get", baseUrlApi("api/permissions/enums"), {
    params
  });
};
//新建
export const addPermissions = (data?: object) => {
  return http.request<any>("post", baseUrlApi("api/permissions"), { data });
};

//获取某个
export const getPermissions = (id: number, params?: object) => {
  return http.request<any>(
    "get",
    baseUrlApi(`api/permissions/${id}?view=UPDATE`),
    {
      params
    }
  );
};
//更新某个
export const updatePermissions = (id: number, data?: object) => {
  return http.request<any>("put", baseUrlApi(`api/permissions/${id}`), {
    data
  });
};
//删除某个

export const deletePermissions = (id: number, data?: object) => {
  return http.request<any>("delete", baseUrlApi(`api/permissions/${id}`), {
    data
  });
};
//列表
export const permissionsList = (params?: object) => {
  return http.request<any>("get", baseUrlApi("api/permissions?view=ADMIN"), {
    params
  });
};

//============================================================================
//菜单 start

//获取参数
export const getMenusEnums = (params?: object) => {
  return http.request<any>("get", baseUrlApi("api/menus/enums"), {
    params
  });
};
//新建
export const addMenus = (data?: object) => {
  return http.request<any>("post", baseUrlApi("api/menus"), { data });
};

//获取某个
export const getMenus = (id: number, params?: object) => {
  return http.request<any>("get", baseUrlApi(`api/menus/${id}?view=UPDATE`), {
    params
  });
};
//更新某个
export const updateMenus = (id: number, data?: object) => {
  return http.request<any>("put", baseUrlApi(`api/menus/${id}`), {
    data
  });
};
//删除某个

export const deleteMenus = (id: number, data?: object) => {
  return http.request<any>("delete", baseUrlApi(`api/menus/${id}`), {
    data
  });
};
//列表
export const menusList = (params?: object) => {
  return http.request<any>("get", baseUrlApi("api/menus?view=ADMIN"), {
    params
  });
};

//============================================================================
//乡村 start

//获取参数
export const getVillagesEnums = (params?: object) => {
  return http.request<any>("get", baseUrlApi("api/villages/enums"), {
    params
  });
};
//新建
export const addVillages = (data?: object) => {
  return http.request<any>("post", baseUrlApi("api/villages"), { data });
};

//获取某个
export const getVillages = (id: number, params?: object) => {
  return http.request<any>(
    "get",
    baseUrlApi(`api/villages/${id}?view=UPDATE`),
    {
      params
    }
  );
};
//更新某个
export const updateVillages = (id: number, data?: object) => {
  return http.request<any>("put", baseUrlApi(`api/villages/${id}`), {
    data
  });
};
//删除某个

export const deleteVillages = (id: number, data?: object) => {
  return http.request<any>("delete", baseUrlApi(`api/villages/${id}`), {
    data
  });
};
//列表
export const villagesList = (params?: object) => {
  return http.request<any>("get", baseUrlApi("api/villages?view=ADMIN"), {
    params
  });
};

//============================================================================
//控制台 start
export const getDashboardOverview = (params?: object) => {
  return http.request<any>("get", baseUrlApi("api/dashboard/overview "), {
    params
  });
};

//============================================================================
//领导 start

//获取参数
export const getLeadersEnums = (params?: object) => {
  return http.request<any>("get", baseUrlApi("api/leaders/enums"), {
    params
  });
};
//新建
export const addLeaders = (data?: object) => {
  return http.request<any>("post", baseUrlApi("api/leaders"), { data });
};

//获取某个
export const getLeaders = (id: number, params?: object) => {
  return http.request<any>("get", baseUrlApi(`api/leaders/${id}?view=UPDATE`), {
    params
  });
};
//更新某个
export const updateLeaders = (id: number, data?: object) => {
  return http.request<any>("put", baseUrlApi(`api/leaders/${id}`), {
    data
  });
};
//删除某个

export const deleteLeaders = (id: number, data?: object) => {
  return http.request<any>("delete", baseUrlApi(`api/leaders/${id}`), {
    data
  });
};
//列表
export const leadersList = (params?: object) => {
  return http.request<any>("get", baseUrlApi("api/leaders?view=ADMIN"), {
    params
  });
};
//============================================================================
//调解人 start

//获取参数
export const getMediatorsEnums = (params?: object) => {
  return http.request<any>("get", baseUrlApi("api/mediators/enums"), {
    params
  });
};
//新建
export const addMediators = (data?: object) => {
  return http.request<any>("post", baseUrlApi("api/mediators"), { data });
};

//获取某个
export const getMediators = (id: number, params?: object) => {
  return http.request<any>(
    "get",
    baseUrlApi(`api/mediators/${id}?view=UPDATE`),
    {
      params
    }
  );
};
//更新某个
export const updateMediators = (id: number, data?: object) => {
  return http.request<any>("put", baseUrlApi(`api/mediators/${id}`), {
    data
  });
};
//删除某个

export const deleteMediators = (id: number, data?: object) => {
  return http.request<any>("delete", baseUrlApi(`api/mediators/${id}`), {
    data
  });
};
//列表
export const mediatorsList = (params?: object) => {
  return http.request<any>("get", baseUrlApi("api/mediators?view=ADMIN"), {
    params
  });
};

//============================================================================
//调解人 start

//获取参数
export const getUsersEnums = (params?: object) => {
  return http.request<any>("get", baseUrlApi("api/users/enums"), {
    params
  });
};
//新建
export const addUsers = (data?: object) => {
  return http.request<any>("post", baseUrlApi("api/users"), { data });
};

//获取某个
export const getUsers = (id: number, params?: object) => {
  return http.request<any>("get", baseUrlApi(`api/users/${id}?view=UPDATE`), {
    params
  });
};
//更新某个
export const updateUsers = (id: number, data?: object) => {
  return http.request<any>("put", baseUrlApi(`api/users/${id}`), {
    data
  });
};
//删除某个

export const deleteUsers = (id: number, data?: object) => {
  return http.request<any>("delete", baseUrlApi(`api/users/${id}`), {
    data
  });
};
//列表
export const usersList = (params?: object, view: string = "ADMIN") => {
  return http.request<any>("get", baseUrlApi(`api/users?view=${view}`), {
    params
  });
};

//更新部分字段
export const patchUsers = (id: number, field: string, data?: object) => {
  return http.request<any>("patch", baseUrlApi(`api/users/${id}/${field}`), {
    data
  });
};

//============================================================================
//任务 start

//获取参数
export const getTasksEnums = (params?: object) => {
  return http.request<any>("get", baseUrlApi("api/tasks/enums"), {
    params
  });
};
//新建
export const addTasks = (data?: object) => {
  return http.request<any>("post", baseUrlApi("api/tasks"), { data });
};

//获取某个
export const getTasks = (id: number, params?: object) => {
  return http.request<any>("get", baseUrlApi(`api/tasks/${id}?view=UPDATE`), {
    params
  });
};
//更新某个
export const updateTasks = (id: number, data?: object) => {
  return http.request<any>("put", baseUrlApi(`api/tasks/${id}`), {
    data
  });
};
//删除某个

export const deleteTasks = (id: number, data?: object) => {
  return http.request<any>("delete", baseUrlApi(`api/tasks/${id}`), {
    data
  });
};
//列表
export const tasksList = (params?: object) => {
  return http.request<any>("get", baseUrlApi("api/tasks?view=ADMIN"), {
    params
  });
};

//============================================================================
//反馈问题 start

//获取参数
export const getIssuesEnums = (params?: object) => {
  return http.request<any>("get", baseUrlApi("api/issues/enums"), {
    params
  });
};
//新建
export const addIssues = (data?: object) => {
  return http.request<any>("post", baseUrlApi("api/issues"), { data });
};

//获取某个
export const getIssues = (id: number, params?: object) => {
  return http.request<any>("get", baseUrlApi(`api/issues/${id}?view=UPDATE`), {
    params
  });
};
//更新某个
export const updateIssues = (id: number, data?: object) => {
  return http.request<any>("put", baseUrlApi(`api/issues/${id}`), {
    data
  });
};
//删除某个

export const deleteIssues = (id: number, data?: object) => {
  return http.request<any>("delete", baseUrlApi(`api/issues/${id}`), {
    data
  });
};
//列表
export const issuesList = (params?: object) => {
  return http.request<any>("get", baseUrlApi("api/issues?view=ADMIN"), {
    params
  });
};

//============================================================================
//五级治理 start

//获取参数
export const getGovernanceEnums = (params?: object) => {
  return http.request<any>("get", baseUrlApi("api/governance/enums"), {
    params
  });
};

//新建
export const addGovernance = (data?: object) => {
  return http.request<any>("post", baseUrlApi("api/governance"), { data });
};

//获取某个
export const getGovernance = (id: number, params?: object) => {
  return http.request<any>(
    "get",
    baseUrlApi(`api/governance/${id}?view=UPDATE`),
    {
      params
    }
  );
};
//更新某个

export const updateGovernance = (id: number, data?: object) => {
  return http.request<any>("put", baseUrlApi(`api/governance/${id}`), { data });
};
//删除某个

export const deleteGovernance = (id: number, data?: object) => {
  return http.request<any>("delete", baseUrlApi(`api/governance/${id}`), {
    data
  });
};
//列表
export const governanceList = (params?: object) => {
  return http.request<any>("get", baseUrlApi("api/governance?view=ADMIN"), {
    params
  });
};

//============================================================================
//乡村美食 start

//获取参数
export const getCuisineEnums = (params?: object) => {
  return http.request<any>("get", baseUrlApi("api/cuisine/enums"), {
    params
  });
};
//新建
export const addCuisine = (pid: number, data?: object) => {
  return http.request<any>("post", baseUrlApi(`api/villages/${pid}/cuisine`), {
    data
  });
};

//获取某个
export const getCuisine = (id: number, params?: object) => {
  return http.request<any>("get", baseUrlApi(`api/cuisine/${id}?view=UPDATE`), {
    params
  });
};
//更新某个
export const updateCuisine = (id: number, data?: object) => {
  return http.request<any>("put", baseUrlApi(`api/cuisine/${id}`), {
    data
  });
};
//删除某个

export const deleteCuisine = (id: number, data?: object) => {
  return http.request<any>("delete", baseUrlApi(`api/cuisine/${id}`), {
    data
  });
};
//列表
export const cuisineList = (pid: number, params?: object) => {
  return http.request<any>(
    "get",
    baseUrlApi(`api/villages/${pid}/cuisine?view=ADMIN`),
    {
      params
    }
  );
};

//============================================================================
//乡村文化名人 start

//获取参数
export const getCulturalPersonsEnums = (params?: object) => {
  return http.request<any>("get", baseUrlApi("api/cultural-persons/enums"), {
    params
  });
};
//新建
export const addCulturalPersons = (pid: number, data?: object) => {
  return http.request<any>(
    "post",
    baseUrlApi(`api/villages/${pid}/cultural-persons`),
    {
      data
    }
  );
};

//获取某个
export const getCulturalPersons = (id: number, params?: object) => {
  return http.request<any>(
    "get",
    baseUrlApi(`api/cultural-persons/${id}?view=UPDATE`),
    {
      params
    }
  );
};
//更新某个
export const updateCulturalPersons = (id: number, data?: object) => {
  return http.request<any>("put", baseUrlApi(`api/cultural-persons/${id}`), {
    data
  });
};
//删除某个

export const deleteCulturalPersons = (id: number, data?: object) => {
  return http.request<any>("delete", baseUrlApi(`api/cultural-persons/${id}`), {
    data
  });
};
//列表
export const culturalPersonsList = (pid: number, params?: object) => {
  return http.request<any>(
    "get",
    baseUrlApi(`api/villages/${pid}/cultural-persons?view=ADMIN`),
    {
      params
    }
  );
};

//============================================================================
//乡村景点 start

//获取参数
export const getSpotsEnums = (params?: object) => {
  return http.request<any>("get", baseUrlApi("api/spots/enums"), {
    params
  });
};
//新建
export const addSpots = (pid: number, data?: object) => {
  return http.request<any>("post", baseUrlApi(`api/villages/${pid}/spots`), {
    data
  });
};

//获取某个
export const getSpots = (id: number, params?: object) => {
  return http.request<any>("get", baseUrlApi(`api/spots/${id}?view=UPDATE`), {
    params
  });
};
//更新某个
export const updateSpots = (id: number, data?: object) => {
  return http.request<any>("put", baseUrlApi(`api/spots/${id}`), {
    data
  });
};
//删除某个

export const deleteSpots = (id: number, data?: object) => {
  return http.request<any>("delete", baseUrlApi(`api/spots/${id}`), {
    data
  });
};
//列表
export const spotsList = (pid: number, params?: object) => {
  return http.request<any>(
    "get",
    baseUrlApi(`api/villages/${pid}/spots?view=ADMIN`),
    {
      params
    }
  );
};

//============================================================================
//我的待办 start

//获取某个
export const getTaskAssignments = (id: number, params?: object) => {
  return http.request<any>("get", baseUrlApi(`api/task-assignments/${id}`), {
    params
  });
};
//列表
export const taskAssignmentsList = (params?: object) => {
  return http.request<any>("get", baseUrlApi("api/me/task-assignments"), {
    params
  });
};
